/* 	* Created: 22/05/2017
	* Last Modified: 22/05/2017
	* Purpose: 
		- Summary Statisticas Data set 
	* DATASETS Used:
		Originals:

		Modified:
		- "$NAPP/Proof2RCoordSubsamplelast.dta" comes from R Mlogit_NAPPHeterov1.R
		
	* DOFILES used:
		- "$CODE/bordersocial.do"
				
	* DATASETS Created:
		- "$NAPP/Proof2new.dta"
		*/	

gl ROOT "C:/Users/`c(username)'/Dropbox"
gl NAPP "$ROOT/NetworkParish2016/Occupational_Choice/Submission/Final_ReStat/Codes/NAPP"
gl OUT "$ROOT/NetworkParish2016/Occupational_Choice/Submission/Final_ReStat/Codes/Results/ReStat"

clear all
use "$NAPP/ReStat/Proof2RCoordSubsamplelast.dta", clear
capt which estout
if _rc ssc install estout 

label val classnew classnew
label def classnew 0 "Professional" 1 "Commercial" 2 "Ind-Artisan" 3 "Ind-Builder" 4 "Ind-Food" 5 "Ind-Services"


// Table 1 : Summary statistics 

eststo summall : estpost summarize AGE married nchild nservant stayerp stayerc
local mtitle ""Total""
levelsof classnew, local(Class)
foreach o of local Class {
	di `o'
	local labelclass`o': label (classnew) `o' 12
	eststo summ`o': estpost summarize AGE married nchild nservant stayerp stayerc if classnew==`o'
	local mtitle "`mtitle' "`labelclass`o''""
}
esttab summ* using "$OUT/table1.tex", replace main(mean %6.3f) aux(sd) mtitle(`mtitle') booktabs

// Appendix 
/*
MOLA: parish(original) name2 (final)
NAPP: name(string) == PARIDGB(numerical)
mola: new_p_name
NAPP: new_address
*/

use "$NAPP/MolaModified_NAPP_JAG3Anew", clear

* Descriptives from map (MOLA)

bys name2: count(new_p_name)
bys name2: count(objectid_1)


* Descriptives from historical census (NAPP)

bys PARIDGB: count(new_address)

* Descriptives from matched data
keep if _merge==3 
bys PARIDGB: count(new_address)
